Ext.onReady(function(){
	
	
	 var viewport = new Ext.Viewport({
	        layout : 'border',
	        items:[
{
    tbar : [{
        xtype:'button',
        text : '新增',
         disabled :true,
        id:'add_button',
        handler : function() {
            var treeid=Ext.getCmp("relate_tree_id").getValue();
            var deep=Ext.getCmp("relate_tree_deep").getValue();
            if(deep!=5){
                Ext.MessageBox.alert("提示","只有关注点才能关联指标")
                return ;
            }
            if(treeid==""){
                Ext.MessageBox.alert("提醒","没有选择任何流程！");
                return ;
            }
            window.showModalDialog("subject_report.jsp?deep="+Ext.getCmp("relate_tree_deep").getValue()+"&id="+Ext.getCmp("relate_tree_id").getValue(), '','dialogWidth=900px;dialogHeight=550px;status:no;resizable:yes;');
            Ext.getCmp("relate_demension_grid").store.load();
        }
    }, '-', {
        xtype:'button',
        text : '删除',
        disabled :true,
        id:'delete_catalog_button',
        handler : function() {
            var row = relate_demension_grid.getSelectionModel().getSelections(); 
            if(row.length==0){
                Ext.MessageBox.alert("提示","请勾选需要删除的指标！")
                return ;
            }
            else{
                Ext.MessageBox.show({
                    title:'提示',
                    msg: '是否确定删除？',
                    buttons:{
                        'yes':'删除',
                        'no':'取消'
                    },
                    fn: save_or_no,
                    animEl: 'delete_process_button',
                    icon: Ext.MessageBox.QUESTION
                });
            }
            function save_or_no(btn){
                if(btn=='yes'){
                    var array=new Array(row.length);
                    for(var i=0;i<row.length;i++){
                        array[i]=row[i].get('refid'); 
                    }
                    var saveItemInfoUrl = "";
                    saveItemInfoUrl = '?className=cn.com.jsepc.rep.process.DeletePointRep';
                    saveItemInfoUrl += '&methodName=DeletePointRep';
                    saveItemInfoUrl += '&paramCount=1'+'&param_0='+ array;

                    saveItemInfoUrl = basePath + 'JarpListener' + saveItemInfoUrl;
                    httpR_itemInfo = getXMLHttpRequest();
                    httpR_itemInfo.onreadystatechange = returnItemUpdate;
                    httpR_itemInfo.open("POST", saveItemInfoUrl, true);
                    httpR_itemInfo.send();
                    function returnItemUpdate() {
                        if (httpR_itemInfo.readyState == 4) {
                            if (httpR_itemInfo.status == 200) { 
                                ret = httpR_itemInfo.responseText;
                                if (ret=='ok'){
                                    Ext.Msg.alert('提示','删除成功！');
                                    var grid = Ext.ComponentMgr.get("relate_demension_grid");
                                    grid.store.reload();
                                }else{
                                    Ext.Msg.alert('提示','删除失败！');
                                }
                            }
                        }
                    }
                }
                else if(btn=='no'){
                    return ;
                }
            };
            
        }
    }
    ],
    region : 'center',
    deferredRender : false,
    activeTab : 0,
    layout : 'border',
    items:[{
        tools : [{
            id : 'refresh',
            handler : function() {
                if(tree_root!=null){
                    tree_root.reload();
                }

            }
        }],   
        title: '流程',
        collapsible : true,   
        split:true,
        layout:'anchor',
        autoScroll:true,
        region : 'west',
        width : 200,
        items:[tree]
       // html : '<div id="process_rep_relate_tree_div"></div>'
    }, {
        region : 'center',
        title:'关联的指标',
        deferredRender : false,
        activeTab : 0,
        layout:"anchor",
        frame : true,
        items:[form_panl,relate_demension_grid]
    //   html : "<div id='panelDiv'></div>"
    //     items : [ panel_query ]
    }
    ]
}
	               ]
	 });
})